package com.ohuang.demo.kotlin

import androidx.compose.runtime.MutableState
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableStateOf


@Stable
class MyList<T> {

    private val size= mutableStateOf(0)
    private val states = mutableListOf<MutableState<T>>()

    fun add(a:T) {
        states.add(mutableStateOf(a))
        size.value++
    }

    fun get(index:Int):T{
        return states[index].value
    }

    fun set(index:Int,value:T){
        states[index].value=value
    }

    fun size():Int{
        return size.value
    }

    fun removeAt(index:Int){
        states.removeAt(index)
        size.value--
    }


}